window.addEventListener('load',function () {
    var rgtel=/^1[3|4|5|7|8]\d{9}$/;//手机号的正则表达式
    var rginp=/^[a-zA-Z1-9-_]{8,16}$/;
    var tel=document.querySelector('#tel');
    var inp=document.querySelector('#inp');
    var sure=document.querySelector('#sure');
    fn(inp,rginp);
    tel.addEventListener('blur',function () { 
        if(rgtel.test(this.value)) {
            console.log('输入正确');
            this.nextElementSibling.className='success';
            this.nextElementSibling.innerHTML='<i class="success_ico"></i>恭喜您输入正确';
            
        }
        else {
            this.nextElementSibling.className='error';
            this.nextElementSibling.innerHTML='<i class="error_ico"></i>手机号码格式不正确，请从新输入  ';
            
        }
     })
     sure.addEventListener('blur',function () {
         if(this.value!=inp.value) {
            this.nextElementSibling.className='error';
            this.nextElementSibling.innerHTML='<i class="error_ico"></i>两次密码不一致请从新输入  ';
         } else {
            this.nextElementSibling.className='';
            this.nextElementSibling.innerHTML='';
         }
       })
     function fn(node,reg) {
         node.addEventListener('blur',function () { 
             if(reg.test(this.value)) {
                 this.nextElementSibling.className='success';
                 this.nextElementSibling.innerHTML='<i class="success_ico"></i>可以使用'
             }else {

                    this.nextElementSibling.className='error';
                    this.nextElementSibling.innerHTML='<i class="error_ico"></i>格式不正确，请从新输入  ';
                  }
          })
     }
     

  })